<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

	<title>SMA Negeri 2 Sidoarjo | Sistem Informasi Manajemen Sekolah</title>

	<!-- Link CSS -->
	
	<script type="text/javascript" src="<?= base_url() ?>js/jquery.js"></script>
	<script src="<?= base_url() ?>js/jquery-1.7.2.min.js"></script>
	<script type="text/javascript" src="<?= base_url() ?>js/jquery.ui.all.js"></script>
	<script type="text/javascript" src="<?= base_url() ?>js/jquery.layout.js"></script>
	<link rel="stylesheet" type="text/css" href="<?= base_url() ?>css/jquery.css" media="screen, tv, projection" title="Default" />
	<link rel="stylesheet" type="text/css" href="<?= base_url() ?>css/lightbox.css" />
	<link rel="stylesheet" type="text/css" href="<?= base_url() ?>css/main.css" media="screen, tv, projection" title="Default" />
	<link rel="stylesheet" type="text/css" href="<?= base_url() ?>css/gridheader.css" media="screen, tv, projection" title="Default" />
	<!--<link rel="stylesheet" type="text/css" href="<?= base_url() ?>css/form/form.css" media="screen, tv, projection" title="Default" />-->
	<link rel="icon" type="image/x-icon" href="<?= base_url() ?>images/logo.png" />
	
	<?if (isset($added_js)){echo $added_js;}?> <!-- attach js flexigrid (jika ada) -->
	
</head>
<style>
	
body {
    background-color: #FFFFFF;
    background-image: url("images/main-bg.gif");
    background-position: 0 0;
    background-repeat: repeat-x;
    color: #7D7D7D;
    font: 11px "Lucida Grande",Arial,Helvetica,sans-serif;
    margin: 12px 0 0;
    padding: 0;
}

#mainpanel{
	width:99%;
	background-color:#FFFFFF;
	margin:auto;
}

</style>
<body>

<!-- JavaScript -->
<script type="text/javascript" src="<?= base_url() ?>js/wufoo.js"></script>
<script src="<?= base_url() ?>js/chosen.jquery.js" type="text/javascript"></script>
<!-- CSS -->
<link rel="stylesheet" type="text/css" href="<?php echo base_url() ?>css/datepicker.css" media="screen, tv, projection" title="Default" />
<script type="text/javascript" src="<?= base_url() ?>js/datepicker.js"></script>
<link rel="stylesheet" href="<?php echo base_url() ?>css/chosen.css" />

<div id="container">
	<?
    //Setting Awal Value Jika Prosedur yang dilakukan adalah prosedur input biasa.
	// $param_exp=explode("#",$param_id);
	$value = array(
		'id'			=> "",
		'kelas'			=> $kelas,
		'pelajaran'		=> $idpel,
		'guru'	=> $guru2,
		'hari'	=> returnday($idday),
		'jamke'	=> $jamke,
		'jamkesampai'	=> "",
		'keterangan'	=> "",
		'legend'				=> "Form Input Jadwal Pelajaran",
		'info'					=> "Form input Jadwal Pelajaran",
		'act_form'				=> "jadwal_pelajaran/input_jadwal_pelajaran/".$idtingkat."/".$idkelas."/".$jamke."/".$idday
	);
	
	//Setting Value pada form Jika melakukan prosedur Edit terhadap data tertentu.
	if($status == "edit"){
		foreach($rs_jadwalbelajar->result() as $row){
			$value['id'] = $row->ID_JJB;
			$value['jamke'] = $row->JAM_KE;
			$value['mulai'] = $row->JAM_MULAI;
			$value['selesai'] = $row->JAM_SELESAI;
			$value['keterangan'] = $row->KETERANGAN;
		}
		$exp_mulai = explode(':',$value['mulai']);
		$value['jam_mulai'] = $exp_mulai[0];
		$value['menit_mulai'] = $exp_mulai[1];
		
		$exp_selesai = explode(':',$value['selesai']);
		$value['jam_selesai'] = $exp_selesai[0];
		$value['menit_selesai'] = $exp_selesai[1];
		
		$value['legend'] = "Form Jadwal Pelajaran";
		$value['info'] = "Form Jadwal Pelajaran";
		$value['act_form'] = "jadwal_pelajaran/edit_jadwalbelajar/".$value['id'];
	}//end if
	
	function returnday($day) {
		$dayname = '';
		switch ($day) { 
			case 1: $dayname  = "Senin"; break; 
			case 2: $dayname  = "Selasa"; break;
			case 3: $dayname  = "Rabu"; break;
			case 4: $dayname  = "Kamis"; break;
			case 5: $dayname  = "Jumat"; break;
			case 6: $dayname  = "Sabtu"; break;
			case 7: $dayname  = "Minggu"; break;
		}
		return $dayname;
	}
	?>
	<?= form_open($value["act_form"],'class="wufoo" name="form_jenisujian"'); ?>
	<fieldset class="fieldset">
	<legend class="legend">
		<?= $value["legend"] ?> |
	</legend>
	
	<div class="info">
		<div><?= $value["info"] ?></div>
	</div>
	
	<?php if (!empty($err_msg)): ?>
		<div class="ret_error">
			<?php echo $err_msg; ?>
		</div>
	<?php endif; ?>
 <!-- Konten -------------------------------------------------------------------------->
 <div id="contentform">
	<ul>
		<li>
			<label class="desc">Kelas</label>
			<div>
				<input readonly style="background:#e0e2e3" class="field text" type="text" maxlength="2" size="10" name="kelas" value="<? if(set_value('kelas')!='') echo set_value('kelas'); else echo $value['kelas'];?>"/> 
			</div>
		</li>
		
		<li>
			<label class="desc">Pelajaran *</label>
			<div>
				 <? 
                //list pelajaran
				$options_pelajaran[''] = "-- Pilih Pelajaran --";
				foreach($pelajaran->result() as $rows){
					$options_pelajaran[$rows->KODE_MATA_PELAJARAN] = $rows->NAMA_MATA_PELAJARAN; 
				}
				echo form_dropdown('pelajaran',$options_pelajaran,$value['pelajaran'],'class="field select"');	
                ?>
			</div>
			<p class="instruct">
				Pilih Pelajaran Pada Kolom ini.			
			</p>
		</li>
		<?php echo form_error('pelajaran'); ?>
		
		<li>
			<label class="desc">Guru *</label>
			<div>
				 <? 
                //list pelajaran
				$options_nip[''] = "-- Pilih Guru --";
					foreach($guru->result() as $role){
						$gelard = ''; $gelarb = '';
						if($role->GELAR_DEPAN != '')
							$gelard = $role->GELAR_DEPAN.'. ';
						if($role->GELAR_BELAKANG != '')
							$gelarb = ', '.$role->GELAR_BELAKANG;
						$nama_gelar = $gelard.$role->NAMA_LENGKAP .$gelarb;
						$options_nip[$role->NIP] = $nama_gelar;
					}
				echo form_dropdown('guru',$options_nip,$value['guru'],'class="chzn-select"');	
                ?>
			</div>
			<p class="instruct">
				Pilih Guru Pada Kolom ini.			
			</p>
		</li>
		<?php echo form_error('guru'); ?>
		
		<li>
			<label class="desc">Hari *</label>
			<div>
				<input readonly style="background:#e0e2e3" class="field text" type="text" size="10" name="hari" value="<? if(set_value('hari')!='') echo set_value('hari'); else echo $value['hari'];?>"/> 
			</div>
			<p class="instruct">
				Pilih Guru Pada Kolom ini.			
			</p>
		</li>
		<?php echo form_error('hari'); ?>
		
		<li>
			<label class="desc">Jam Ke *</label>
			<div>
				<input readonly style="background:#e0e2e3" class="field text" type="text" maxlength="2" size="3" name="jamke" value="<? if(set_value('jamke')!='') echo set_value('jamke'); else echo $value['jamke'];?>"/> s/d 
				<input class="field text" type="text" maxlength="2" size="3" name="jamkesampai" value="<? if(set_value('jamkesampai')!='') echo set_value('jamkesampai'); else echo $value['jamkesampai'];?>"/>
			</div>
			<p class="instruct">
				Masukkan Jam Ke Pada Kolom ini.			
			</p>
		</li>
		<?php echo form_error('jamkesampai'); ?>
		
		<li>
			<label class="desc">Keterangan</label>
			<div>
				<textarea rows="4" cols="40" name="keterangan" value="<? if(set_value('keterangan')!='') echo set_value('keterangan'); else echo $value['keterangan'];?>"><?php echo $value['keterangan']?></textarea>
			</div>
			<p class="instruct">
				Masukkan Keterangan Pada Kolom ini.			
			</p>
		</li>
		<?php echo form_error('keterangan'); ?>
		<input id="idtingkat" name="idtingkat" type="hidden" value="<?=$idtingkat?>">
		<input id="idday" name="idday" type="hidden" value="<?=$idday?>">
		<input id="idkelas" name="idkelas" type="hidden" value="<?=$idkelas?>">
		
		<li class="buttons">
		  <input id="saveForm" class="btTxt" type="submit" value="Simpan" />
		  <input name="submit" type="reset" value="Batal" />
		</li>
	</ul>
</div>
</fieldset>

<script type="text/javascript">
  $(".chzn-select").chosen();
  $(".chzn-select-deselect").chosen({allow_single_deselect:true});
</script>	
<?= form_close(); ?>
</form>
</div><!--container-->

</body>
</html>